package ru.study.thinkin.chapter12;

import java.io.*;

class WrapCheckedException {
	void throwRuntimeException(int type){
		try {
			switch(type) {
				case 0: throw new FileNotFoundException();
				case 1: throw new IOException("ИО");
				case 2: throw new RuntimeException("ХЗ");
				default: return;
			}		
		} catch (Exception e) {
			throw new RuntimeException(e);
		}	
	}
}

public class TurnOffChecked {
	
	public static void main(String[] args) {
		WrapCheckedException wce = new WrapCheckedException();
		//wce.throwRubtimeException(1);
		
		System.out.println("==Другой вариант");
		for (int i =0;i<=3;i++){
			try {
				wce.throwRuntimeException(i);
			} catch (RuntimeException re) {				
				try{
					throw re.getCause();
				}catch(FileNotFoundException ioe) {
					System.out.println("IO поймано");
					ioe.printStackTrace(System.out);
				}catch(Throwable t) {
					t.printStackTrace(System.err);
				}				
			}			
		}
		System.out.println("finish");
	}	
}
